<template>
  <div class="lotTooLingHistory">
    <el-row>
      <el-col :span="24">
        <dynForm :info-form="searchForm" :search-tags="searchTags" :select-list="selectList">
          <el-button
            type="primary"
            icon="el-icon-search"
            @click="doSearch"
          >
            {{ $t("search") }}</el-button>
        </dynForm>
      </el-col>
    </el-row>
    <el-card class="box-card" shadow="never">
      <el-row>
        <!-- 表单主体内容 -->
        <dynTable
          ref="dynTable"
          :loading="tableLoading"
          :table-data="tableData"
          :table-columns="tableColumns"
        />
        <!--分页组件-->
        <pagination
          :total="total"
          :page.sync="listQuery.page"
          :limit.sync="listQuery.limit"
          @pagination="getList"
        />
      </el-row>
    </el-card>
  </div>
</template>
<script>
import mySetting from '@/mixins/mySetting'
import lotToolingApis from '@/api/assistance/lotToolingHistory'
import eqpBaseApi from '@/api/equipment/eqpbase'
export default {
  name: 'LotTooLingHistory',
  mixins: [mySetting],
  data() {
    return {
      searchForm: {},
      searchTags: [
        { label: this.$t('MESBatchNumber'), prop: 'lotId', tag: 'DynInput' },
        { label: this.$t('eqpName'), prop: 'eqpId', tag: 'DynSelect' },
        { label: this.$t('toolingType'), prop: 'toolingType', tag: 'DynInput' },
        { label: this.$t('testingTime'), prop: '', tag: 'Dyndaterange', event: (value) => {
          this.searchForm.startTrackinStamp = Array.isArray(value) ? value[0] : null
          this.searchForm.endTrackinStamp = Array.isArray(value) ? value[1] : null
        } }
      ],
      selectList: {},
      tableColumns: [
        { prop: '', label: this.$t('index'), type: 'index', width: '50px', templete: (_scope) => {
          return (
            <span>{ (this.listQuery.page - 1) * this.listQuery.size + _scope.$index + 1 }</span>
          )
        } },
        {
          prop: 'lotID',
          label: this.$t('MESBatchNumber')
        },
        {
          prop: 'trackinStamp',
          label: this.$t('trackinStamp')
        },
        {
          prop: 'eqpID',
          label: this.$t('eqpName')
        },
        {
          prop: 'siteID',
          label: this.$t('tapingStation')
        },
        {
          prop: 'toolingBarcode',
          label: this.$t('toolingBarcode')
        },
        {
          prop: 'toolingType',
          label: this.$t('toolingType')
        },
        {
          prop: 'systemTime',
          label: this.$t('testingTime')
        }
      ],
      tableLoading: true
    }
  },
  computed: {},
  watch: {},
  created() {
    this.initList()
    this.getEqpNameList()
  },
  mounted() {},
  methods: {
    doSearch() {
      this.listQuery.page = 1
      this.initList()
    },
    // 初始化列表
    async initList() {
      const res = await lotToolingApis.getList(this.$clearNull({ ...this.searchForm, ...this.listQuery }))
      this.tableData = res.data
      this.total = res.total
      this.tableLoading = false
    },
    // 切换分页
    getList(val) {
      this.listQuery = val
      this.initList()
    },
    // 获取设备名称
    async getEqpNameList() {
      const res = await eqpBaseApi.eqpnamelist()
      this.$set(this.selectList, 'eqpId', res.data)
    }
  }
}
</script>
<style lang='scss' scoped>
@import "~@/assets/styles/defaultStyle.scss";
</style>
